﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using COFE.Core.Utils;
using COFE.Core.Validater;
using COFE.Core.Filter;
using COFE.Core;

namespace COFE.Core.EntryType
{
    /// <summary>
    /// This IconProvider uses the embedded folder/file.iconBitmap resource to return an icon.
    /// </summary>
    public class ResourceIconProvider : IEntryTypeIconProvider
    {
        public static ResourceIconProvider Instance = new ResourceIconProvider();


        #region Constructor
        public ResourceIconProvider()
        {
            _folder = new Bitmap(ResourceUtils.GetEmbeddedResource(this, "EntryType\\Resources\\folder.ico"));
            _file = new Bitmap(ResourceUtils.GetEmbeddedResource(this, "EntryType\\Resources\\file.ico"));
        }
        #endregion

        #region Methods


        public byte[] GetIconStream(IEntryFilter filter, IconProperties size)
        {


            if (filter != null)
            {
                if (filter is FileTypeEntryFilter)
                {
                    string ext = (filter as FileTypeEntryFilter).Value;
                    if (ext == "folder")
                        return _folder.EnsureBitmapSize(size).ConvertToBitmapArray();
                    else
                        return _file.EnsureBitmapSize(size).ConvertToBitmapArray();
                }
            }

            return _file.EnsureBitmapSize(size).ConvertToBitmapArray();
        }


        #endregion

        #region Data

        Bitmap _folder, _file;

        #endregion

        #region Public Properties

        #endregion



    }
}
